<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
	<th:block th:include="include :: header('新增设备')" />
	<th:block th:include="include :: datetimepicker-css" />
</head>

<body class="white-bg">

	<div class="col-sm-12 search-collapse">
		<form id="formId">
			<div class="select-list">
				<ul>
					<li>
						<label>设备名称：</label>
						<input type="text" name="deviceName" />
					</li>
					<li>
						<label>架构：</label>
						<input type="text" name="architecture" />
					</li>
					<li>
						<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
								class="fa fa-search"></i>&nbsp;搜索</a>
						<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
								class="fa fa-refresh"></i>&nbsp;重置</a>
					</li>
				</ul>
			</div>
		</form>
	</div>
	<div class="col-sm-12 select-table table-striped">
		<table id="bootstrap-table"></table>
	</div>

	<th:block th:include="include :: footer" />
	<th:block th:include="include :: datetimepicker-js" />
	<script th:inline="javascript">
		var editFlag = [[${@permission.hasPermi('device:manage:edit')}]];
		var removeFlag = [[${@permission.hasPermi('device:manage:remove')}]];
		var prefix = ctx + "device/manage";
		var prefix_task = ctx + "task/manage";

		$(function () {
			var options = {
				url: prefix + "/list",
				createUrl: prefix + "/add",
				updateUrl: prefix_task + "/edit/{id}",
				removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
				modalName: "设备",
				columns: [{
					checkbox: true
				},
				{
					field: 'deviceId',
					title: '设备ID',
					visible: false
				},
				{
					field: 'deviceName',
					title: '设备名称'
				},
				{
					field: 'type',
					title: '设备类型'
				},
				{
					field: 'state',
					title: '设备状态'
				},
				{
					field: 'architecture',
					title: '架构'
				},
				{
					field: 'ip',
					title: '设备ip地址'
				},
				{
					field: 'gmtCreate',
					title: '创建时间'
				},
				{
					title: '操作',
					align: 'center',
					formatter: function (value, row, index) {
						var actions = [];
						actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="addTask(\'' + row.deviceId + '\')"><i class="fa fa-edit"></i>启动任务</a> ');
						return actions.join('');
					}
				}]
			};
			$.table.init(options);
		});
		
		function addTask(deviceId) {
			var data = { "deviceId": deviceId };
			$.operate.save(prefix_task + "/add", data);
		}

	</script>
</body>

</html>